package com.tch.controller;


import com.alibaba.fastjson.JSONObject;
import com.tch.util.HttpUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import javax.servlet.http.HttpServletRequest;
import java.io.File;




@RestController
@Slf4j
public class UploadPdfController {

    @Autowired
    HttpUtils httpUtils;

    @PostMapping(value={"/pdfFile"})
    public String pushPDF(HttpServletRequest request,@RequestBody String path){

        if (StringUtils.isNotEmpty(path)){
            //File file = new File("D:\\IJworkspace\\springboot\\src\\main\\resources\\log\\35D8931651FDB113.pdf");
            JSONObject str = JSONObject.parseObject(path);
            String pathStr = str.getString("path");
            log.info("pathStr__"+pathStr);
            File file = new File(pathStr);
            String result = HttpUtils.sendPostFile("http://171.166.90.100:12003/fileServer/fileUpServerPdf", file);
             //String result = HttpUtils.sendPostFile("https://wsbs.shxga.gov.cn/crj/api/zkk.jsp",file);
            log.info("传输pdf返回结果______________" + result);
            return result;
        }else{
            return "参数path解析失败。";
        }
    }



}
